package com.ustb.springboot.controller;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ustb.springboot.entity.AnswerSlideEntity;
import com.ustb.springboot.service.AnswerSlideService;
import com.ustb.springboot.common.utils.R;

import javax.servlet.http.HttpServletRequest;


/**
 * @author pyn
 * @date 2022-05-17 11:26:55
 */
@RestController
@RequestMapping("answerslide")
public class AnswerSlideController {
    @Autowired
    private AnswerSlideService answerSlideService;


    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("answerslide:save")
    public R save(HttpServletRequest request, @RequestBody AnswerSlideEntity answerSlide) {
        return answerSlideService.save(request, answerSlide);
    }


    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("answerslide:delete")
    public R delete(@RequestBody Map<String, Object> body) {
        return answerSlideService.delete(body);
    }

    @RequestMapping("/summerize")
    @RequiresPermissions("answerslide:summerize")
    public R summerize(@RequestBody Map<String, Object> body){
        Map<String,Object> summerizeScore = new HashMap<String , Object>();
        summerizeScore = answerSlideService.summerizeSlide(body);
        if (null == summerizeScore)
            return R.ok(2000, "暂无信息!");
        else
            return R.ok(20000, "查询成功!").put("summerize_slide",summerizeScore);
    }
}
